<?php
class ListNode {
    public $val = 0;
    public $next = null;
    function __construct($val)
    {
        $this->val = $val;
    }
}

class Solution {
    /**
     * 用栈来存储，先进后出
     * @param ListNode $head
     * @return Integer[]
     */
    function reversePrint($head) {
        if ($head == null) {
            return array();
        }
        $data = array();
        $curr = $head;
        while ($curr != null) {
            array_unshift($data, $curr->val);
            $curr = $curr->next;
        }
        return $data;
    }
}